<?php

require_once 'propel/om/BaseObject.php';

require_once 'propel/om/Persistent.php';


include_once 'propel/util/Criteria.php';

include_once 'cms/menu/om/MenuItemPeer.php';

/**
 * Base class that represents a row from the 'menu_item' table.
 *
 * 
 *
 * @package cms.menu.om.om
 */
abstract class BaseMenuItem extends BaseObject  implements Persistent {


	/**
	 * The Peer class.
	 * Instance provides a convenient way of calling static methods on a class
	 * that calling code may not be able to identify.
	 * @var MenuItemPeer
	 */
	protected static $peer;


	/**
	 * The value for the menu_item_id field.
	 * @var int
	 */
	protected $menu_item_id;


	/**
	 * The value for the position field.
	 * @var int
	 */
	protected $position = 0;


	/**
	 * The value for the is_separator field.
	 * @var boolean
	 */
	protected $is_separator = false;


	/**
	 * The value for the link field.
	 * @var string
	 */
	protected $link;


	/**
	 * The value for the category_id field.
	 * @var int
	 */
	protected $category_id;


	/**
	 * The value for the parent_id field.
	 * @var int
	 */
	protected $parent_id = 0;


	/**
	 * The value for the menu_id field.
	 * @var int
	 */
	protected $menu_id;


	/**
	 * The value for the thumbnail_id field.
	 * @var int
	 */
	protected $thumbnail_id;


	/**
	 * The value for the image_id field.
	 * @var int
	 */
	protected $image_id;

	/**
	 * @var Category
	 */
	protected $aCategory;

	/**
	 * @var Menu
	 */
	protected $aMenu;

	/**
	 * @var MenuItem
	 */
	protected $aMenuItemRelatedByParentId;

	/**
	 * @var Image
	 */
	protected $aImageRelatedByThumbnailId;

	/**
	 * @var Image
	 */
	protected $aImageRelatedByImageId;

	/**
	 * Collection to store aggregation of collMenuItemsRelatedByParentId.
	 * @var array
	 */
	protected $collMenuItemsRelatedByParentId;

	/**
	 * The criteria used to select the current contents of collMenuItemsRelatedByParentId.
	 * @var Criteria
	 */
	protected $lastMenuItemRelatedByParentIdCriteria = null;

	/**
	 * Collection to store aggregation of collMenuItemI18ns.
	 * @var array
	 */
	protected $collMenuItemI18ns;

	/**
	 * The criteria used to select the current contents of collMenuItemI18ns.
	 * @var Criteria
	 */
	protected $lastMenuItemI18nCriteria = null;

	/**
	 * Flag to prevent endless save loop, if this object is referenced
	 * by another object which falls in this transaction.
	 * @var boolean
	 */
	protected $alreadyInSave = false;

	/**
	 * Flag to prevent endless validation loop, if this object is referenced
	 * by another object which falls in this transaction.
	 * @var boolean
	 */
	protected $alreadyInValidation = false;

	/**
	 * Get the [menu_item_id] column value.
	 * 
	 * @return int
	 */
	public function getMenuItemId()
	{

		return $this->menu_item_id;
	}

	/**
	 * Get the [position] column value.
	 * 
	 * @return int
	 */
	public function getPosition()
	{

		return $this->position;
	}

	/**
	 * Get the [is_separator] column value.
	 * 
	 * @return boolean
	 */
	public function getIsSeparator()
	{

		return $this->is_separator;
	}

	/**
	 * Get the [link] column value.
	 * 
	 * @return string
	 */
	public function getLink()
	{

		return $this->link;
	}

	/**
	 * Get the [category_id] column value.
	 * 
	 * @return int
	 */
	public function getCategoryId()
	{

		return $this->category_id;
	}

	/**
	 * Get the [parent_id] column value.
	 * 
	 * @return int
	 */
	public function getParentId()
	{

		return $this->parent_id;
	}

	/**
	 * Get the [menu_id] column value.
	 * 
	 * @return int
	 */
	public function getMenuId()
	{

		return $this->menu_id;
	}

	/**
	 * Get the [thumbnail_id] column value.
	 * 
	 * @return int
	 */
	public function getThumbnailId()
	{

		return $this->thumbnail_id;
	}

	/**
	 * Get the [image_id] column value.
	 * 
	 * @return int
	 */
	public function getImageId()
	{

		return $this->image_id;
	}

	/**
	 * Set the value of [menu_item_id] column.
	 * 
	 * @param int $v new value
	 * @return void
	 */
	public function setMenuItemId($v)
	{

		if ($this->menu_item_id !== $v) {
			$this->menu_item_id = $v;
			$this->modifiedColumns[] = MenuItemPeer::MENU_ITEM_ID;
		}

	} // setMenuItemId()

	/**
	 * Set the value of [position] column.
	 * 
	 * @param int $v new value
	 * @return void
	 */
	public function setPosition($v)
	{

		if ($this->position !== $v || $v === 0) {
			$this->position = $v;
			$this->modifiedColumns[] = MenuItemPeer::POSITION;
		}

	} // setPosition()

	/**
	 * Set the value of [is_separator] column.
	 * 
	 * @param boolean $v new value
	 * @return void
	 */
	public function setIsSeparator($v)
	{

		if ($this->is_separator !== $v || $v === false) {
			$this->is_separator = $v;
			$this->modifiedColumns[] = MenuItemPeer::IS_SEPARATOR;
		}

	} // setIsSeparator()

	/**
	 * Set the value of [link] column.
	 * 
	 * @param string $v new value
	 * @return void
	 */
	public function setLink($v)
	{

		if ($this->link !== $v) {
			$this->link = $v;
			$this->modifiedColumns[] = MenuItemPeer::LINK;
		}

	} // setLink()

	/**
	 * Set the value of [category_id] column.
	 * 
	 * @param int $v new value
	 * @return void
	 */
	public function setCategoryId($v)
	{

		if ($this->category_id !== $v) {
			$this->category_id = $v;
			$this->modifiedColumns[] = MenuItemPeer::CATEGORY_ID;
		}

		if ($this->aCategory !== null && $this->aCategory->getCategoryId() !== $v) {
			$this->aCategory = null;
		}

	} // setCategoryId()

	/**
	 * Set the value of [parent_id] column.
	 * 
	 * @param int $v new value
	 * @return void
	 */
	public function setParentId($v)
	{

		if ($this->parent_id !== $v || $v === 0) {
			$this->parent_id = $v;
			$this->modifiedColumns[] = MenuItemPeer::PARENT_ID;
		}

		if ($this->aMenuItemRelatedByParentId !== null && $this->aMenuItemRelatedByParentId->getMenuItemId() !== $v) {
			$this->aMenuItemRelatedByParentId = null;
		}

	} // setParentId()

	/**
	 * Set the value of [menu_id] column.
	 * 
	 * @param int $v new value
	 * @return void
	 */
	public function setMenuId($v)
	{

		if ($this->menu_id !== $v) {
			$this->menu_id = $v;
			$this->modifiedColumns[] = MenuItemPeer::MENU_ID;
		}

		if ($this->aMenu !== null && $this->aMenu->getMenuId() !== $v) {
			$this->aMenu = null;
		}

	} // setMenuId()

	/**
	 * Set the value of [thumbnail_id] column.
	 * 
	 * @param int $v new value
	 * @return void
	 */
	public function setThumbnailId($v)
	{

		if ($this->thumbnail_id !== $v) {
			$this->thumbnail_id = $v;
			$this->modifiedColumns[] = MenuItemPeer::THUMBNAIL_ID;
		}

		if ($this->aImageRelatedByThumbnailId !== null && $this->aImageRelatedByThumbnailId->getImageId() !== $v) {
			$this->aImageRelatedByThumbnailId = null;
		}

	} // setThumbnailId()

	/**
	 * Set the value of [image_id] column.
	 * 
	 * @param int $v new value
	 * @return void
	 */
	public function setImageId($v)
	{

		if ($this->image_id !== $v) {
			$this->image_id = $v;
			$this->modifiedColumns[] = MenuItemPeer::IMAGE_ID;
		}

		if ($this->aImageRelatedByImageId !== null && $this->aImageRelatedByImageId->getImageId() !== $v) {
			$this->aImageRelatedByImageId = null;
		}

	} // setImageId()

	/**
	 * Hydrates (populates) the object variables with values from the database resultset.
	 *
	 * An offset (1-based "start column") is specified so that objects can be hydrated
	 * with a subset of the columns in the resultset rows.  This is needed, for example,
	 * for results of JOIN queries where the resultset row includes columns from two or
	 * more tables.
	 *
	 * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
	 * @param int $startcol 1-based offset column which indicates which restultset column to start with.
	 * @return int next starting column
	 * @throws PropelException  - Any caught Exception will be rewrapped as a PropelException.
	 */
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->menu_item_id = $rs->getInt($startcol + 0);

			$this->position = $rs->getInt($startcol + 1);

			$this->is_separator = $rs->getBoolean($startcol + 2);

			$this->link = $rs->getString($startcol + 3);

			$this->category_id = $rs->getInt($startcol + 4);

			$this->parent_id = $rs->getInt($startcol + 5);

			$this->menu_id = $rs->getInt($startcol + 6);

			$this->thumbnail_id = $rs->getInt($startcol + 7);

			$this->image_id = $rs->getInt($startcol + 8);

			$this->setNew(false);

			// FIXME - using NUM_COLUMNS may be clearer.
			return $startcol + 9; // 9 = MenuItemPeer::NUM_COLUMNS - MenuItemPeer::NUM_LAZY_LOAD_COLUMNS).

		} catch (Exception $e) {
			throw new PropelException("Error populating MenuItem object", $e);
		}
	}

	/**
	 * Removes this object from datastore and sets delete attribute.
	 *
	 * @param Connection $con
	 * @return void
	 * @throws PropelException
	 * @see BaseObject::setDeleted()
	 * @see BaseObject::isDeleted()
	 */
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(MenuItemPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			MenuItemPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	/**
	 * Stores the object in the database.  If the object is new,
	 * it inserts it; otherwise an update is performed.  This method
	 * wraps the doSave() worker method in a transaction.
	 *
	 * @param Connection $con
	 * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
	 * @throws PropelException
	 * @see doSave()
	 */
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(MenuItemPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	/**
	 * Stores the object in the database.
	 *
	 * If the object is new, it inserts it; otherwise an update is performed.
	 * All related objects are also updated in this method.
	 *
	 * @param Connection $con
	 * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
	 * @throws PropelException
	 * @see save()
	 */
	protected function doSave($con)
	{
		$affectedRows = 0; // initialize var to track total num of affected rows
		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


			// We call the save method on the following object(s) if they
			// were passed to this object by their coresponding set
			// method.  This object relates to these object(s) by a
			// foreign key reference.

			if ($this->aCategory !== null) {
				if ($this->aCategory->isModified()) {
					$affectedRows += $this->aCategory->save($con);
				}
				$this->setCategory($this->aCategory);
			}

			if ($this->aMenu !== null) {
				if ($this->aMenu->isModified()) {
					$affectedRows += $this->aMenu->save($con);
				}
				$this->setMenu($this->aMenu);
			}

			if ($this->aMenuItemRelatedByParentId !== null) {
				if ($this->aMenuItemRelatedByParentId->isModified()) {
					$affectedRows += $this->aMenuItemRelatedByParentId->save($con);
				}
				$this->setMenuItemRelatedByParentId($this->aMenuItemRelatedByParentId);
			}

			if ($this->aImageRelatedByThumbnailId !== null) {
				if ($this->aImageRelatedByThumbnailId->isModified()) {
					$affectedRows += $this->aImageRelatedByThumbnailId->save($con);
				}
				$this->setImageRelatedByThumbnailId($this->aImageRelatedByThumbnailId);
			}

			if ($this->aImageRelatedByImageId !== null) {
				if ($this->aImageRelatedByImageId->isModified()) {
					$affectedRows += $this->aImageRelatedByImageId->save($con);
				}
				$this->setImageRelatedByImageId($this->aImageRelatedByImageId);
			}


			// If this object has been modified, then save it to the database.
			if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = MenuItemPeer::doInsert($this, $con);
					$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
										 // should always be true here (even though technically
										 // BasePeer::doInsert() can insert multiple rows).

					$this->setMenuItemId($pk);  //[IMV] update autoincrement primary key

					$this->setNew(false);
				} else {
					$affectedRows += MenuItemPeer::doUpdate($this, $con);
				}
				$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
			}

			if ($this->collMenuItemsRelatedByParentId !== null) {
				foreach($this->collMenuItemsRelatedByParentId as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collMenuItemI18ns !== null) {
				foreach($this->collMenuItemI18ns as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} // doSave()

	/**
	 * Array of ValidationFailed objects.
	 * @var array ValidationFailed[]
	 */
	protected $validationFailures = array();

	/**
	 * Gets any ValidationFailed objects that resulted from last call to validate().
	 *
	 *
	 * @return array ValidationFailed[]
	 * @see validate()
	 */
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	/**
	 * Validates the objects modified field values and all objects related to this table.
	 *
	 * If $columns is either a column name or an array of column names
	 * only those columns are validated.
	 *
	 * @param mixed $columns Column name or an array of column names.
	 * @return boolean Whether all columns pass validation.
	 * @see doValidate()
	 * @see getValidationFailures()
	 */
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	/**
	 * This function performs the validation work for complex object models.
	 *
	 * In addition to checking the current object, all related objects will
	 * also be validated.  If all pass then <code>true</code> is returned; otherwise
	 * an aggreagated array of ValidationFailed objects will be returned.
	 *
	 * @param array $columns Array of column names to validate.
	 * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
	 */
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			// We call the validate method on the following object(s) if they
			// were passed to this object by their coresponding set
			// method.  This object relates to these object(s) by a
			// foreign key reference.

			if ($this->aCategory !== null) {
				if (!$this->aCategory->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures());
				}
			}

			if ($this->aMenu !== null) {
				if (!$this->aMenu->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aMenu->getValidationFailures());
				}
			}

			if ($this->aMenuItemRelatedByParentId !== null) {
				if (!$this->aMenuItemRelatedByParentId->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aMenuItemRelatedByParentId->getValidationFailures());
				}
			}

			if ($this->aImageRelatedByThumbnailId !== null) {
				if (!$this->aImageRelatedByThumbnailId->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aImageRelatedByThumbnailId->getValidationFailures());
				}
			}

			if ($this->aImageRelatedByImageId !== null) {
				if (!$this->aImageRelatedByImageId->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aImageRelatedByImageId->getValidationFailures());
				}
			}


			if (($retval = MenuItemPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}


				if ($this->collMenuItemI18ns !== null) {
					foreach($this->collMenuItemI18ns as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}


			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	/**
	 * Retrieves a field from the object by name passed in as a string.
	 *
	 * @param string $name name
	 * @param string $type The type of fieldname the $name is of:
	 *                     one of the class type constants TYPE_PHPNAME,
	 *                     TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
	 * @return mixed Value of field.
	 */
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = MenuItemPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	/**
	 * Retrieves a field from the object by Position as specified in the xml schema.
	 * Zero-based.
	 *
	 * @param int $pos position in xml schema
	 * @return mixed Value of field at $pos
	 */
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getMenuItemId();
				break;
			case 1:
				return $this->getPosition();
				break;
			case 2:
				return $this->getIsSeparator();
				break;
			case 3:
				return $this->getLink();
				break;
			case 4:
				return $this->getCategoryId();
				break;
			case 5:
				return $this->getParentId();
				break;
			case 6:
				return $this->getMenuId();
				break;
			case 7:
				return $this->getThumbnailId();
				break;
			case 8:
				return $this->getImageId();
				break;
			default:
				return null;
				break;
		} // switch()
	}

	/**
	 * Exports the object as an array.
	 *
	 * You can specify the key type of the array by passing one of the class
	 * type constants.
	 *
	 * @param string $keyType One of the class type constants TYPE_PHPNAME,
	 *                        TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
	 * @return an associative array containing the field names (as keys) and field values
	 */
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = MenuItemPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getMenuItemId(),
			$keys[1] => $this->getPosition(),
			$keys[2] => $this->getIsSeparator(),
			$keys[3] => $this->getLink(),
			$keys[4] => $this->getCategoryId(),
			$keys[5] => $this->getParentId(),
			$keys[6] => $this->getMenuId(),
			$keys[7] => $this->getThumbnailId(),
			$keys[8] => $this->getImageId(),
		);
		return $result;
	}

	/**
	 * Sets a field from the object by name passed in as a string.
	 *
	 * @param string $name peer name
	 * @param mixed $value field value
	 * @param string $type The type of fieldname the $name is of:
	 *                     one of the class type constants TYPE_PHPNAME,
	 *                     TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
	 * @return void
	 */
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = MenuItemPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	/**
	 * Sets a field from the object by Position as specified in the xml schema.
	 * Zero-based.
	 *
	 * @param int $pos position in xml schema
	 * @param mixed $value field value
	 * @return void
	 */
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setMenuItemId($value);
				break;
			case 1:
				$this->setPosition($value);
				break;
			case 2:
				$this->setIsSeparator($value);
				break;
			case 3:
				$this->setLink($value);
				break;
			case 4:
				$this->setCategoryId($value);
				break;
			case 5:
				$this->setParentId($value);
				break;
			case 6:
				$this->setMenuId($value);
				break;
			case 7:
				$this->setThumbnailId($value);
				break;
			case 8:
				$this->setImageId($value);
				break;
		} // switch()
	}

	/**
	 * Populates the object using an array.
	 *
	 * This is particularly useful when populating an object from one of the
	 * request arrays (e.g. $_POST).  This method goes through the column
	 * names, checking to see whether a matching key exists in populated
	 * array. If so the setByName() method is called for that column.
	 *
	 * You can specify the key type of the array by additionally passing one
	 * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
	 * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
	 *
	 * @param array  $arr     An array to populate the object from.
	 * @param string $keyType The type of keys the array uses.
	 * @return void
	 */
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = MenuItemPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setMenuItemId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setPosition($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setIsSeparator($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setLink($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setCategoryId($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setParentId($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setMenuId($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setThumbnailId($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setImageId($arr[$keys[8]]);
	}

	/**
	 * Build a Criteria object containing the values of all modified columns in this object.
	 *
	 * @return Criteria The Criteria object containing all modified values.
	 */
	public function buildCriteria()
	{
		$criteria = new Criteria(MenuItemPeer::DATABASE_NAME);

		if ($this->isColumnModified(MenuItemPeer::MENU_ITEM_ID)) $criteria->add(MenuItemPeer::MENU_ITEM_ID, $this->menu_item_id);
		if ($this->isColumnModified(MenuItemPeer::POSITION)) $criteria->add(MenuItemPeer::POSITION, $this->position);
		if ($this->isColumnModified(MenuItemPeer::IS_SEPARATOR)) $criteria->add(MenuItemPeer::IS_SEPARATOR, $this->is_separator);
		if ($this->isColumnModified(MenuItemPeer::LINK)) $criteria->add(MenuItemPeer::LINK, $this->link);
		if ($this->isColumnModified(MenuItemPeer::CATEGORY_ID)) $criteria->add(MenuItemPeer::CATEGORY_ID, $this->category_id);
		if ($this->isColumnModified(MenuItemPeer::PARENT_ID)) $criteria->add(MenuItemPeer::PARENT_ID, $this->parent_id);
		if ($this->isColumnModified(MenuItemPeer::MENU_ID)) $criteria->add(MenuItemPeer::MENU_ID, $this->menu_id);
		if ($this->isColumnModified(MenuItemPeer::THUMBNAIL_ID)) $criteria->add(MenuItemPeer::THUMBNAIL_ID, $this->thumbnail_id);
		if ($this->isColumnModified(MenuItemPeer::IMAGE_ID)) $criteria->add(MenuItemPeer::IMAGE_ID, $this->image_id);

		return $criteria;
	}

	/**
	 * Builds a Criteria object containing the primary key for this object.
	 *
	 * Unlike buildCriteria() this method includes the primary key values regardless
	 * of whether or not they have been modified.
	 *
	 * @return Criteria The Criteria object containing value(s) for primary key(s).
	 */
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(MenuItemPeer::DATABASE_NAME);

		$criteria->add(MenuItemPeer::MENU_ITEM_ID, $this->menu_item_id);

		return $criteria;
	}

	/**
	 * Returns the primary key for this object (row).
	 * @return int
	 */
	public function getPrimaryKey()
	{
		return $this->getMenuItemId();
	}

	/**
	 * Generic method to set the primary key (menu_item_id column).
	 *
	 * @param int $key Primary key.
	 * @return void
	 */
	public function setPrimaryKey($key)
	{
		$this->setMenuItemId($key);
	}

	/**
	 * Sets contents of passed object to values from current object.
	 *
	 * If desired, this method can also make copies of all associated (fkey referrers)
	 * objects.
	 *
	 * @param object $copyObj An object of MenuItem (or compatible) type.
	 * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
	 * @throws PropelException
	 */
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setPosition($this->position);

		$copyObj->setIsSeparator($this->is_separator);

		$copyObj->setLink($this->link);

		$copyObj->setCategoryId($this->category_id);

		$copyObj->setParentId($this->parent_id);

		$copyObj->setMenuId($this->menu_id);

		$copyObj->setThumbnailId($this->thumbnail_id);

		$copyObj->setImageId($this->image_id);


		if ($deepCopy) {
			// important: temporarily setNew(false) because this affects the behavior of
			// the getter/setter methods for fkey referrer objects.
			$copyObj->setNew(false);

			foreach($this->getMenuItemsRelatedByParentId() as $relObj) {
				if($this->getPrimaryKey() === $relObj->getPrimaryKey()) {
						continue;
				}

				$copyObj->addMenuItemRelatedByParentId($relObj->copy($deepCopy));
			}

			foreach($this->getMenuItemI18ns() as $relObj) {
				$copyObj->addMenuItemI18n($relObj->copy($deepCopy));
			}

		} // if ($deepCopy)


		$copyObj->setNew(true);

		$copyObj->setMenuItemId(NULL); // this is a pkey column, so set to default value

	}

	/**
	 * Makes a copy of this object that will be inserted as a new row in table when saved.
	 * It creates a new object filling in the simple attributes, but skipping any primary
	 * keys that are defined for the table.
	 *
	 * If desired, this method can also make copies of all associated (fkey referrers)
	 * objects.
	 *
	 * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
	 * @return MenuItem Clone of current object.
	 * @throws PropelException
	 */
	public function copy($deepCopy = false)
	{
		// we use get_class(), because this might be a subclass
		$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	/**
	 * Returns a peer instance associated with this om.
	 *
	 * Since Peer classes are not to have any instance attributes, this method returns the
	 * same instance for all member of this class. The method could therefore
	 * be static, but this would prevent one from overriding the behavior.
	 *
	 * @return MenuItemPeer
	 */
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new MenuItemPeer();
		}
		return self::$peer;
	}

	/**
	 * Declares an association between this object and a Category object.
	 *
	 * @param Category $v
	 * @return void
	 * @throws PropelException
	 */
	public function setCategory($v)
	{


		if ($v === null) {
			$this->setCategoryId(NULL);
		} else {
			$this->setCategoryId($v->getCategoryId());
		}


		$this->aCategory = $v;
	}


	/**
	 * Get the associated Category object
	 *
	 * @param Connection Optional Connection object.
	 * @return Category The associated Category object.
	 * @throws PropelException
	 */
	public function getCategory($con = null)
	{
		// include the related Peer class
		include_once 'cms/core/om/om/BaseCategoryPeer.php';

		if ($this->aCategory === null && ($this->category_id !== null)) {

			$this->aCategory = CategoryPeer::retrieveByPK($this->category_id, $con);

			/* The following can be used instead of the line above to
			   guarantee the related object contains a reference
			   to this object, but this level of coupling
			   may be undesirable in many circumstances.
			   As it can lead to a db query with many results that may
			   never be used.
			   $obj = CategoryPeer::retrieveByPK($this->category_id, $con);
			   $obj->addCategorys($this);
			 */
		}
		return $this->aCategory;
	}

	/**
	 * Declares an association between this object and a Menu object.
	 *
	 * @param Menu $v
	 * @return void
	 * @throws PropelException
	 */
	public function setMenu($v)
	{


		if ($v === null) {
			$this->setMenuId(NULL);
		} else {
			$this->setMenuId($v->getMenuId());
		}


		$this->aMenu = $v;
	}


	/**
	 * Get the associated Menu object
	 *
	 * @param Connection Optional Connection object.
	 * @return Menu The associated Menu object.
	 * @throws PropelException
	 */
	public function getMenu($con = null)
	{
		// include the related Peer class
		include_once 'cms/menu/om/om/BaseMenuPeer.php';

		if ($this->aMenu === null && ($this->menu_id !== null)) {

			$this->aMenu = MenuPeer::retrieveByPK($this->menu_id, $con);

			/* The following can be used instead of the line above to
			   guarantee the related object contains a reference
			   to this object, but this level of coupling
			   may be undesirable in many circumstances.
			   As it can lead to a db query with many results that may
			   never be used.
			   $obj = MenuPeer::retrieveByPK($this->menu_id, $con);
			   $obj->addMenus($this);
			 */
		}
		return $this->aMenu;
	}

	/**
	 * Declares an association between this object and a MenuItem object.
	 *
	 * @param MenuItem $v
	 * @return void
	 * @throws PropelException
	 */
	public function setMenuItemRelatedByParentId($v)
	{


		if ($v === null) {
			$this->setParentId('NULL');
		} else {
			$this->setParentId($v->getMenuItemId());
		}


		$this->aMenuItemRelatedByParentId = $v;
	}


	/**
	 * Get the associated MenuItem object
	 *
	 * @param Connection Optional Connection object.
	 * @return MenuItem The associated MenuItem object.
	 * @throws PropelException
	 */
	public function getMenuItemRelatedByParentId($con = null)
	{
		// include the related Peer class
		include_once 'cms/menu/om/om/BaseMenuItemPeer.php';

		if ($this->aMenuItemRelatedByParentId === null && ($this->parent_id !== null)) {

			$this->aMenuItemRelatedByParentId = MenuItemPeer::retrieveByPK($this->parent_id, $con);

			/* The following can be used instead of the line above to
			   guarantee the related object contains a reference
			   to this object, but this level of coupling
			   may be undesirable in many circumstances.
			   As it can lead to a db query with many results that may
			   never be used.
			   $obj = MenuItemPeer::retrieveByPK($this->parent_id, $con);
			   $obj->addMenuItemsRelatedByParentId($this);
			 */
		}
		return $this->aMenuItemRelatedByParentId;
	}

	/**
	 * Declares an association between this object and a Image object.
	 *
	 * @param Image $v
	 * @return void
	 * @throws PropelException
	 */
	public function setImageRelatedByThumbnailId($v)
	{


		if ($v === null) {
			$this->setThumbnailId(NULL);
		} else {
			$this->setThumbnailId($v->getImageId());
		}


		$this->aImageRelatedByThumbnailId = $v;
	}


	/**
	 * Get the associated Image object
	 *
	 * @param Connection Optional Connection object.
	 * @return Image The associated Image object.
	 * @throws PropelException
	 */
	public function getImageRelatedByThumbnailId($con = null)
	{
		// include the related Peer class
		include_once 'cms/core/om/om/BaseImagePeer.php';

		if ($this->aImageRelatedByThumbnailId === null && ($this->thumbnail_id !== null)) {

			$this->aImageRelatedByThumbnailId = ImagePeer::retrieveByPK($this->thumbnail_id, $con);

			/* The following can be used instead of the line above to
			   guarantee the related object contains a reference
			   to this object, but this level of coupling
			   may be undesirable in many circumstances.
			   As it can lead to a db query with many results that may
			   never be used.
			   $obj = ImagePeer::retrieveByPK($this->thumbnail_id, $con);
			   $obj->addImagesRelatedByThumbnailId($this);
			 */
		}
		return $this->aImageRelatedByThumbnailId;
	}

	/**
	 * Declares an association between this object and a Image object.
	 *
	 * @param Image $v
	 * @return void
	 * @throws PropelException
	 */
	public function setImageRelatedByImageId($v)
	{


		if ($v === null) {
			$this->setImageId(NULL);
		} else {
			$this->setImageId($v->getImageId());
		}


		$this->aImageRelatedByImageId = $v;
	}


	/**
	 * Get the associated Image object
	 *
	 * @param Connection Optional Connection object.
	 * @return Image The associated Image object.
	 * @throws PropelException
	 */
	public function getImageRelatedByImageId($con = null)
	{
		// include the related Peer class
		include_once 'cms/core/om/om/BaseImagePeer.php';

		if ($this->aImageRelatedByImageId === null && ($this->image_id !== null)) {

			$this->aImageRelatedByImageId = ImagePeer::retrieveByPK($this->image_id, $con);

			/* The following can be used instead of the line above to
			   guarantee the related object contains a reference
			   to this object, but this level of coupling
			   may be undesirable in many circumstances.
			   As it can lead to a db query with many results that may
			   never be used.
			   $obj = ImagePeer::retrieveByPK($this->image_id, $con);
			   $obj->addImagesRelatedByImageId($this);
			 */
		}
		return $this->aImageRelatedByImageId;
	}

	/**
	 * Temporary storage of collMenuItemsRelatedByParentId to save a possible db hit in
	 * the event objects are add to the collection, but the
	 * complete collection is never requested.
	 * @return void
	 */
	public function initMenuItemsRelatedByParentId()
	{
		if ($this->collMenuItemsRelatedByParentId === null) {
			$this->collMenuItemsRelatedByParentId = array();
		}
	}

	/**
	 * If this collection has already been initialized with
	 * an identical criteria, it returns the collection.
	 * Otherwise if this MenuItem has previously
	 * been saved, it will retrieve related MenuItemsRelatedByParentId from storage.
	 * If this MenuItem is new, it will return
	 * an empty collection or the current collection, the criteria
	 * is ignored on a new object.
	 *
	 * @param Connection $con
	 * @param Criteria $criteria
	 * @throws PropelException
	 */
	public function getMenuItemsRelatedByParentId($criteria = null, $con = null)
	{
		// include the Peer class
		include_once 'cms/menu/om/om/BaseMenuItemPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collMenuItemsRelatedByParentId === null) {
			if ($this->isNew()) {
			   $this->collMenuItemsRelatedByParentId = array();
			} else {

				$criteria->add(MenuItemPeer::PARENT_ID, $this->getMenuItemId());

				MenuItemPeer::addSelectColumns($criteria);
				$this->collMenuItemsRelatedByParentId = MenuItemPeer::doSelect($criteria, $con);
			}
		} else {
			// criteria has no effect for a new object
			if (!$this->isNew()) {
				// the following code is to determine if a new query is
				// called for.  If the criteria is the same as the last
				// one, just return the collection.


				$criteria->add(MenuItemPeer::PARENT_ID, $this->getMenuItemId());

				MenuItemPeer::addSelectColumns($criteria);
				if (!isset($this->lastMenuItemRelatedByParentIdCriteria) || !$this->lastMenuItemRelatedByParentIdCriteria->equals($criteria)) {
					$this->collMenuItemsRelatedByParentId = MenuItemPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastMenuItemRelatedByParentIdCriteria = $criteria;
		return $this->collMenuItemsRelatedByParentId;
	}

	/**
	 * Returns the number of related MenuItemsRelatedByParentId.
	 *
	 * @param Criteria $criteria
	 * @param boolean $distinct
	 * @param Connection $con
	 * @throws PropelException
	 */
	public function countMenuItemsRelatedByParentId($criteria = null, $distinct = false, $con = null)
	{
		// include the Peer class
		include_once 'cms/menu/om/om/BaseMenuItemPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(MenuItemPeer::PARENT_ID, $this->getMenuItemId());

		return MenuItemPeer::doCount($criteria, $distinct, $con);
	}

	/**
	 * Method called to associate a MenuItem object to this object
	 * through the MenuItem foreign key attribute
	 *
	 * @param MenuItem $l MenuItem
	 * @return void
	 * @throws PropelException
	 */
	public function addMenuItemRelatedByParentId(MenuItem $l)
	{
		$this->collMenuItemsRelatedByParentId[] = $l;
		$l->setMenuItemRelatedByParentId($this);
	}


	/**
	 * If this collection has already been initialized with
	 * an identical criteria, it returns the collection.
	 * Otherwise if this MenuItem is new, it will return
	 * an empty collection; or if this MenuItem has previously
	 * been saved, it will retrieve related MenuItemsRelatedByParentId from storage.
	 *
	 * This method is protected by default in order to keep the public
	 * api reasonable.  You can provide public methods for those you
	 * actually need in MenuItem.
	 */
	public function getMenuItemsRelatedByParentIdJoinCategory($criteria = null, $con = null)
	{
		// include the Peer class
		include_once 'cms/menu/om/om/BaseMenuItemPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collMenuItemsRelatedByParentId === null) {
			if ($this->isNew()) {
				$this->collMenuItemsRelatedByParentId = array();
			} else {

				$criteria->add(MenuItemPeer::PARENT_ID, $this->getMenuItemId());

				$this->collMenuItemsRelatedByParentId = MenuItemPeer::doSelectJoinCategory($criteria, $con);
			}
		} else {
			// the following code is to determine if a new query is
			// called for.  If the criteria is the same as the last
			// one, just return the collection.

			$criteria->add(MenuItemPeer::PARENT_ID, $this->getMenuItemId());

			if (!isset($this->lastMenuItemRelatedByParentIdCriteria) || !$this->lastMenuItemRelatedByParentIdCriteria->equals($criteria)) {
				$this->collMenuItemsRelatedByParentId = MenuItemPeer::doSelectJoinCategory($criteria, $con);
			}
		}
		$this->lastMenuItemRelatedByParentIdCriteria = $criteria;

		return $this->collMenuItemsRelatedByParentId;
	}


	/**
	 * If this collection has already been initialized with
	 * an identical criteria, it returns the collection.
	 * Otherwise if this MenuItem is new, it will return
	 * an empty collection; or if this MenuItem has previously
	 * been saved, it will retrieve related MenuItemsRelatedByParentId from storage.
	 *
	 * This method is protected by default in order to keep the public
	 * api reasonable.  You can provide public methods for those you
	 * actually need in MenuItem.
	 */
	public function getMenuItemsRelatedByParentIdJoinMenu($criteria = null, $con = null)
	{
		// include the Peer class
		include_once 'cms/menu/om/om/BaseMenuItemPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collMenuItemsRelatedByParentId === null) {
			if ($this->isNew()) {
				$this->collMenuItemsRelatedByParentId = array();
			} else {

				$criteria->add(MenuItemPeer::PARENT_ID, $this->getMenuItemId());

				$this->collMenuItemsRelatedByParentId = MenuItemPeer::doSelectJoinMenu($criteria, $con);
			}
		} else {
			// the following code is to determine if a new query is
			// called for.  If the criteria is the same as the last
			// one, just return the collection.

			$criteria->add(MenuItemPeer::PARENT_ID, $this->getMenuItemId());

			if (!isset($this->lastMenuItemRelatedByParentIdCriteria) || !$this->lastMenuItemRelatedByParentIdCriteria->equals($criteria)) {
				$this->collMenuItemsRelatedByParentId = MenuItemPeer::doSelectJoinMenu($criteria, $con);
			}
		}
		$this->lastMenuItemRelatedByParentIdCriteria = $criteria;

		return $this->collMenuItemsRelatedByParentId;
	}


	/**
	 * If this collection has already been initialized with
	 * an identical criteria, it returns the collection.
	 * Otherwise if this MenuItem is new, it will return
	 * an empty collection; or if this MenuItem has previously
	 * been saved, it will retrieve related MenuItemsRelatedByParentId from storage.
	 *
	 * This method is protected by default in order to keep the public
	 * api reasonable.  You can provide public methods for those you
	 * actually need in MenuItem.
	 */
	public function getMenuItemsRelatedByParentIdJoinImageRelatedByThumbnailId($criteria = null, $con = null)
	{
		// include the Peer class
		include_once 'cms/menu/om/om/BaseMenuItemPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collMenuItemsRelatedByParentId === null) {
			if ($this->isNew()) {
				$this->collMenuItemsRelatedByParentId = array();
			} else {

				$criteria->add(MenuItemPeer::PARENT_ID, $this->getMenuItemId());

				$this->collMenuItemsRelatedByParentId = MenuItemPeer::doSelectJoinImageRelatedByThumbnailId($criteria, $con);
			}
		} else {
			// the following code is to determine if a new query is
			// called for.  If the criteria is the same as the last
			// one, just return the collection.

			$criteria->add(MenuItemPeer::PARENT_ID, $this->getMenuItemId());

			if (!isset($this->lastMenuItemRelatedByParentIdCriteria) || !$this->lastMenuItemRelatedByParentIdCriteria->equals($criteria)) {
				$this->collMenuItemsRelatedByParentId = MenuItemPeer::doSelectJoinImageRelatedByThumbnailId($criteria, $con);
			}
		}
		$this->lastMenuItemRelatedByParentIdCriteria = $criteria;

		return $this->collMenuItemsRelatedByParentId;
	}


	/**
	 * If this collection has already been initialized with
	 * an identical criteria, it returns the collection.
	 * Otherwise if this MenuItem is new, it will return
	 * an empty collection; or if this MenuItem has previously
	 * been saved, it will retrieve related MenuItemsRelatedByParentId from storage.
	 *
	 * This method is protected by default in order to keep the public
	 * api reasonable.  You can provide public methods for those you
	 * actually need in MenuItem.
	 */
	public function getMenuItemsRelatedByParentIdJoinImageRelatedByImageId($criteria = null, $con = null)
	{
		// include the Peer class
		include_once 'cms/menu/om/om/BaseMenuItemPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collMenuItemsRelatedByParentId === null) {
			if ($this->isNew()) {
				$this->collMenuItemsRelatedByParentId = array();
			} else {

				$criteria->add(MenuItemPeer::PARENT_ID, $this->getMenuItemId());

				$this->collMenuItemsRelatedByParentId = MenuItemPeer::doSelectJoinImageRelatedByImageId($criteria, $con);
			}
		} else {
			// the following code is to determine if a new query is
			// called for.  If the criteria is the same as the last
			// one, just return the collection.

			$criteria->add(MenuItemPeer::PARENT_ID, $this->getMenuItemId());

			if (!isset($this->lastMenuItemRelatedByParentIdCriteria) || !$this->lastMenuItemRelatedByParentIdCriteria->equals($criteria)) {
				$this->collMenuItemsRelatedByParentId = MenuItemPeer::doSelectJoinImageRelatedByImageId($criteria, $con);
			}
		}
		$this->lastMenuItemRelatedByParentIdCriteria = $criteria;

		return $this->collMenuItemsRelatedByParentId;
	}

	/**
	 * Temporary storage of collMenuItemI18ns to save a possible db hit in
	 * the event objects are add to the collection, but the
	 * complete collection is never requested.
	 * @return void
	 */
	public function initMenuItemI18ns()
	{
		if ($this->collMenuItemI18ns === null) {
			$this->collMenuItemI18ns = array();
		}
	}

	/**
	 * If this collection has already been initialized with
	 * an identical criteria, it returns the collection.
	 * Otherwise if this MenuItem has previously
	 * been saved, it will retrieve related MenuItemI18ns from storage.
	 * If this MenuItem is new, it will return
	 * an empty collection or the current collection, the criteria
	 * is ignored on a new object.
	 *
	 * @param Connection $con
	 * @param Criteria $criteria
	 * @throws PropelException
	 */
	public function getMenuItemI18ns($criteria = null, $con = null)
	{
		// include the Peer class
		include_once 'cms/menu/om/om/BaseMenuItemI18nPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collMenuItemI18ns === null) {
			if ($this->isNew()) {
			   $this->collMenuItemI18ns = array();
			} else {

				$criteria->add(MenuItemI18nPeer::MENU_ITEM_ID, $this->getMenuItemId());

				MenuItemI18nPeer::addSelectColumns($criteria);
				$this->collMenuItemI18ns = MenuItemI18nPeer::doSelect($criteria, $con);
			}
		} else {
			// criteria has no effect for a new object
			if (!$this->isNew()) {
				// the following code is to determine if a new query is
				// called for.  If the criteria is the same as the last
				// one, just return the collection.


				$criteria->add(MenuItemI18nPeer::MENU_ITEM_ID, $this->getMenuItemId());

				MenuItemI18nPeer::addSelectColumns($criteria);
				if (!isset($this->lastMenuItemI18nCriteria) || !$this->lastMenuItemI18nCriteria->equals($criteria)) {
					$this->collMenuItemI18ns = MenuItemI18nPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastMenuItemI18nCriteria = $criteria;
		return $this->collMenuItemI18ns;
	}

	/**
	 * Returns the number of related MenuItemI18ns.
	 *
	 * @param Criteria $criteria
	 * @param boolean $distinct
	 * @param Connection $con
	 * @throws PropelException
	 */
	public function countMenuItemI18ns($criteria = null, $distinct = false, $con = null)
	{
		// include the Peer class
		include_once 'cms/menu/om/om/BaseMenuItemI18nPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(MenuItemI18nPeer::MENU_ITEM_ID, $this->getMenuItemId());

		return MenuItemI18nPeer::doCount($criteria, $distinct, $con);
	}

	/**
	 * Method called to associate a MenuItemI18n object to this object
	 * through the MenuItemI18n foreign key attribute
	 *
	 * @param MenuItemI18n $l MenuItemI18n
	 * @return void
	 * @throws PropelException
	 */
	public function addMenuItemI18n(MenuItemI18n $l)
	{
		$this->collMenuItemI18ns[] = $l;
		$l->setMenuItem($this);
	}


	/**
	 * If this collection has already been initialized with
	 * an identical criteria, it returns the collection.
	 * Otherwise if this MenuItem is new, it will return
	 * an empty collection; or if this MenuItem has previously
	 * been saved, it will retrieve related MenuItemI18ns from storage.
	 *
	 * This method is protected by default in order to keep the public
	 * api reasonable.  You can provide public methods for those you
	 * actually need in MenuItem.
	 */
	public function getMenuItemI18nsJoinLanguage($criteria = null, $con = null)
	{
		// include the Peer class
		include_once 'cms/menu/om/om/BaseMenuItemI18nPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collMenuItemI18ns === null) {
			if ($this->isNew()) {
				$this->collMenuItemI18ns = array();
			} else {

				$criteria->add(MenuItemI18nPeer::MENU_ITEM_ID, $this->getMenuItemId());

				$this->collMenuItemI18ns = MenuItemI18nPeer::doSelectJoinLanguage($criteria, $con);
			}
		} else {
			// the following code is to determine if a new query is
			// called for.  If the criteria is the same as the last
			// one, just return the collection.

			$criteria->add(MenuItemI18nPeer::MENU_ITEM_ID, $this->getMenuItemId());

			if (!isset($this->lastMenuItemI18nCriteria) || !$this->lastMenuItemI18nCriteria->equals($criteria)) {
				$this->collMenuItemI18ns = MenuItemI18nPeer::doSelectJoinLanguage($criteria, $con);
			}
		}
		$this->lastMenuItemI18nCriteria = $criteria;

		return $this->collMenuItemI18ns;
	}

} // BaseMenuItem
